package com.googlecode.cnasort.cc.rmi.common;

import java.util.Map;

public class Debug
{
    public static String toDebugString()
    {
        StringBuilder builder = new StringBuilder();

        builder.append("\n*******************************");
        builder.append("\n*******************************");
        builder.append("\n*******************************");
        builder.append("Debug [getenv()=");
        builder.append(toString(System.getenv()));

        builder.append("\n, getProperties()=");
        builder.append(toString(System.getProperties()));

        builder.append("\n]");
        builder.append("\n*******************************");
        builder.append("\n*******************************");
        builder.append("\n*******************************");

        return builder.toString();
    }

    public static String toString( final Map<?,?> map)
    {
        StringBuilder builder = new StringBuilder();

        for( Map.Entry<?,?> entry : map.entrySet() ) {
            builder.append("\n[");
            builder.append( entry.getKey() );
            builder.append("]=[");
            builder.append( entry.getValue() );
            builder.append(']');
        }
        return builder.toString();
    }
}
